package com.yl.order;

import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;

import com.jeremyliao.liveeventbus.LiveEventBus;
import com.net.yl.entity.ActivateEntity;
import com.net.yl.entity.SyncStoreEntity;
import com.yl.common.utils.LogUtil;
import com.yl.common.utils.ToastUtil;

import java.util.List;

/**
 * create by cjx on 2024/4/7
 * desc:
 */
public class App extends Application {
    public static App app;

    public ActivateEntity activateInfo;
    public SyncStoreEntity storeInfo;
    public String favicon;
    public boolean isConnected = false;
    public boolean viewLock = false;
    public int serialNumber = 1;

//    public HashMap<Integer, Boolean> sensorMap = new HashMap<>();

    @Override
    public void onCreate() {
        super.onCreate();
        App.app = this;
        LogUtil.getInstance().log("APP", "\n\n------ 启动程序 ------");
        ToastUtil.getInstance().init(this);
        LiveEventBus.config().autoClear(true);
    }

    public void killActivities() {
        ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.AppTask> appTaskList = activityManager.getAppTasks();
        for (ActivityManager.AppTask appTask : appTaskList) {
            appTask.finishAndRemoveTask();
        }
        System.exit(0);
    }

}
